﻿using System.ComponentModel;
using System.Web;
using System.Web.Mvc;
using xTeam.HengLe.DataAccess;
using xTeam.HengLe.Entity;
using System.Collections.Generic;
using System.Web.Routing;

namespace xTeam.HengLe.Controller.Website {
    public class GuestBookController : BaseController {
        protected override void Initialize(RequestContext requestContext) {
            base.Initialize(requestContext);
            this.SiteMapPathAdd(ViewsResources.SiteMapPath.GuestBook, Url.Action("Index"));
        }
        /// <summary>
        /// 留言簿主页
        /// </summary>
        public ActionResult Index() {
            return RedirectToAction("List");
        }
        /// <summary>
        /// 留言簿主页
        /// </summary>
        public ActionResult List(int pageIndex = 1, int productId = 0) {
            this.SiteMapPathAdd(ViewsResources.SiteMapPath.List);
            GuestBookViewModel viewModel = new GuestBookViewModel();
            viewModel.GuestBookList = _guestBookDataAccess.Search(productId);
            return View(viewModel);
        }
        // 编辑
        [HttpPost]
        public ActionResult Edit(GuestBookViewModel gvm) {
            _guestBookDataAccess.Edit(gvm.GuestBookInfo);
            return this.RedirectToAction("Preview", "Product", new { productId = gvm.GuestBookInfo.ProductId });
        }
    }
}
